package day017.exception;

public class Exception_Throw2 {
    public static void main(String[] args) {
        int[] arr = {1, 2, 3, 4, 5};
        arr = null;
        printArr2(arr);
    }

    public static void printArr1(int[] arr) {
        if (arr == null) {
            System.out.println("数组为null");
        } else {
            for (int i = 0; i < arr.length; i++) {
                System.out.println(arr[i]);
            }
        }
    }

    public static void printArr2(int[] arr) {
        if (arr == null) {
            throw new RuntimeException("数组为空！");
        } else {
            for (int i = 0; i < arr.length; i++) {
                System.out.println(arr[i]);
            }
        }
    }
}
